/*
	Copyright (c) 2011 Canadensys
*/
package net.canadensys.dataportal.vascan.config.impl;

import net.canadensys.dataportal.vascan.config.AbstractConfigValidator;
import net.canadensys.dataportal.vascan.config.InstallationConfigIF;


/**
 * This class is responsible to validate the installation configuration.
 * If something is not valid, a message will be written in the Logger.
 */
public class InstallationConfigValidator extends AbstractConfigValidator{
	
	
	/**
	 * This function validates the configuration contained in the InstallationConfig static class.
	 * @return configuration valid or not
	 */
	@Override
	public boolean validateConfiguration(InstallationConfigIF targetedConfiguration){
		boolean isValid = true;
		//mandatory config
		isValid = isValid && testMandatoryConfiguration(targetedConfiguration,InstallationConfig.VASCAN_ROOT_URL_KEY);
		isValid = isValid && testMandatoryConfiguration(targetedConfiguration,InstallationConfig.PUBLIC_DOWNLOAD_URL_KEY);
		isValid = isValid && testMandatoryConfiguration(targetedConfiguration,InstallationConfig.LUCENE_DIR_KEY);
		isValid = isValid && testMandatoryConfiguration(targetedConfiguration,InstallationConfig.GENERATED_IMAGES_DIR_KEY);
		isValid = isValid && testMandatoryConfiguration(targetedConfiguration,InstallationConfig.GENERATED_CONTENT_DIR_KEY);
		
		if(isValid){
			isValid = isValid && testAndSetWorkFolder(targetedConfiguration,InstallationConfig.GENERATED_IMAGES_DIR_KEY);
			isValid = isValid && testAndSetWorkFolder(targetedConfiguration,InstallationConfig.GENERATED_CONTENT_DIR_KEY);
		}
		return isValid;
	}
}
